package com.sky.service.user.impl;

import com.sky.constant.StatusConstant;
import com.sky.entity.Setmeal;
import com.sky.mapper.user.SetmealMapper;
import com.sky.service.user.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Service("userSetmealService")
public class SetmealServiceImpl implements SetmealService {

    @Autowired
    private SetmealMapper setmealMapper;



    /**
     * 根据分类id查询套餐
     *
     * @param categoryId
     * @return
     */
    @Override
    public List<Setmeal> selectSetmeal(Long categoryId) {

        List<Setmeal> setmealList = setmealMapper.selectSetmeal(categoryId);
        log.warn("小程序查询到的setmealList为{}", setmealList);

        //        log.warn("根据分类id查询套餐{}", collect);
        return setmealList.stream().filter(setmeal -> ObjectUtils.equals(setmeal.getStatus(), StatusConstant.ENABLE)).collect(Collectors.toList());
//        return setmealList.stream().filter(setmeal -> setmeal.getStatus() == StatusConstant.ENABLE).collect(Collectors.toList());
//        return setmealList;

    }
}
